package com.sun.androidexerciseproject.function.security;

/**
 * Created by Administrator on 2017/8/5 0005.
 */

public class RSATest {
    public static void main(String[] args) {
        RSA rsa = RSA.getInstance();
        String privateKey = rsa.getPrivateKey();
        String publicKey = rsa.getPulicKey();
        System.out.println("privateKey = \n" + privateKey);
        System.out.println("publicKey = \n" + publicKey);
        System.out.println("after");
//        rsa.updateKey();
//        String privateKey2 = rsa.getPrivateKey();
//        String publicKey2 = rsa.getPulicKey();
//        System.out.println("privateKey2 = \n" + privateKey2);
//        System.out.println("publicKey2 = \n" + publicKey2);
//        System.out.println("len = " + publicKey.length());
//        if (Objects.equals(privateKey, privateKey2)) {
//            System.out.println("privateKey  = privateKey2");
//        } else {
//            System.out.println("privateKey  != privateKey2");
//        }
//        if (Objects.equals(publicKey, publicKey2)) {
//            System.out.println("publicKey  = publicKey2");
//        } else {
//            System.out.println("publicKey  != publicKey2");
//        }
        String plaintText = "1111";
        System.out.println("plaintText = \n" + plaintText);
        String encryptText = rsa.encrypyByPublic(plaintText);
        System.out.println("encryptText = \n" + encryptText);
        plaintText = rsa.decryptByPrivate(encryptText);
        System.out.println("plaintText = \n" + plaintText);
    }
}
